﻿
@inject ISysFieldTypeService DbCodeService
@model DbFieldRelationTypeEntity

@{
    ViewData["Title"] = "字段映射关系 编辑";
    Layout = "../Shared/_Layout.cshtml";
}
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-lg-12">
            <div class="ibox float-e-margins">
                <div class="ibox-content text-center p-md">
                    <form id="dynamic-form" asp-action="Edit" method="post" class="form-horizontal" role="form">
                        <div asp-validation-summary="@ValidationSummary.All" class="text-danger"></div>
                        <input type="hidden" asp-for="DbFieldRelationTypeId" />

                        <div class="form-group">
                            <label asp-for="DbProviderId" class="col-md-3 control-label text-right"> 数据库类型</label>
                            <div class="col-md-9  text-left">
                                <div class="input-group m-b">
                                    <span class="input-group-addon">*</span>
                                    <select asp-for="DbProviderId" class="select2">
                                        @{
                                            var lst = ConvertHelper.ToEnumList(typeof(ProviderType), true);
                                            if (lst != null && lst.Count > 0)
                                            {
                                                foreach (var item in lst)
                                                {
                                                    @Html.Raw("<option value='" + item.Key + "' " + (item.Key == Model.DbProviderId ? "selected" : "") + ">" + item.Value + "</option>")
                                                }
                                            }
                                        }
                                    </select>
                                </div>
                                <span asp-validation-for="DbProviderId" class="text-danger"></span>
                            </div>
                        </div>
                        <div class="form-group">
                            <label asp-for="DbTypeName" class="col-md-3 control-label text-right"> 字段名称</label>
                            <div class="col-md-9  text-left">
                                <div class="input-group m-b">
                                    <span class="input-group-addon">*</span>
                                    <input asp-for="DbTypeName" class="form-control" validate="{required:true ,maxlength:50   }" />
                                </div>
                                <span asp-validation-for="DbTypeName" class="text-danger"></span>
                            </div>
                        </div>
                        <div class="form-group">
                            <label asp-for="SysFieldTypeId" class="col-md-3 control-label text-right"> 系统类型</label>
                            <div class="col-md-9  text-left">
                                <div class="input-group m-b">
                                    <span class="input-group-addon">*</span>
                                    <select asp-for="SysFieldTypeId" class="select2">
                                        @{
                                            var lstType = DbCodeService.GetAll();
                                            if (lstType != null && lstType.Count > 0)
                                            {
                                                foreach (var item in lstType)
                                                {
                                                    @Html.Raw("<option value='" + item.SysFieldTypeId + "' " + (item.SysFieldTypeId == Model.SysFieldTypeId ? "selected" : "") + ">" + item.DbTypeName + "</option>")
                                                }
                                            }
                                        }
                                    </select>
                                </div>
                                <span asp-validation-for="SysFieldTypeId" class="text-danger"></span>
                            </div>
                        </div>                        <div class="form-group">
                            <div class="col-sm-4 col-sm-offset-2">
                                <a class="btn btn-white" asp-action="index">返  回</a>

                                <button class="btn btn-primary" type="submit">保存</button>
                            </div>
                        </div>

                    </form>
                </div>
            </div>
        </div>
    </div>
</div>

@section scripts{
    <script type="text/javascript">
    $(function () {
        $(document).ready(function () {
            $(".form-horizontal").CustomForm({
                isValidate: true,
                isTable: false
            });
            $(".form-horizontal").submit(function () {
                if (!$(".form-horizontal").valid())
                {
                    return false;
                }
            });
	  });
    });
    </script>
}